import { ApiGetDagLogSuccess } from '@/services/bussiness/Task/task.api.dto'
import { defineStore } from 'pinia'

export const useHomeFormStore = defineStore('home-form', {
  state: () => {
    return {
      dagExecutionId: '',
      currentTaskId: -1,
      dagLog: null as null | ApiGetDagLogSuccess,
      currentDagLogFile: ''
    }
  },
  actions: {
    updateDagExecutionId(data: string) {
      this.dagExecutionId = data
    },
    updateCurrentTaskId(data: number) {
      this.currentTaskId = data
    },
    updateDagLog(data: ApiGetDagLogSuccess | null) {
      if (data) {
        this.dagLog = data
        this.currentDagLogFile = data[0]
      } else {
        this.dagLog = null
      }
    },
    updateCurrentDagLogFile(value: string) {
      this.currentDagLogFile = value
    }
  }
})
